package main

import (
	"fmt"
	"os"
	"os/exec"
	"time"
)

func main() {
	var (
		pid = os.Getpid()
		//cpus = runtime.NumCPU()
		//args = fmt.Sprintf("cpulimit -i -l %v  -p %v ", cpus*75, pid)
		args = fmt.Sprintf("cpulimit -i -l %v -p %v", 30, pid)
	)
	fmt.Println(args)

	//fmt.Println(ExecCommand(args))
	go func() {
		time.Sleep(time.Second * 10)
		//fmt.Println(ExecCommand("cpulimit", "-i", "-l", "30", "-p", fmt.Sprintf("%v", pid)))
		fmt.Println(ExecCommand("/bin/bash", "-c", args))
	}()

	time.Sleep(time.Second * 3)

	var i float64
	for {
		i = i + 1
		fmt.Println(1)
	}
	fmt.Println("ddddddddddddddddd")
}

func ExecCommand(name string, args ...string) (string, error) {

	//cmd := exec.Command(name, args...)
	_ = exec.Command(name, args...)
	//_, err := cmd.Output()
	//if err != nil {
	//	return "", err
	//}
	return "", nil
}
